#! coding=utf-8
from app import db
import datetime


class Topic(db.Model):
    __bind_key__ = 'jie'
    __tablename__ = 'ugc_topic'
    __table_args__ = {'mysql_charset': 'utf8mb4', 'mysql_engine': 'InnoDB'}

    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.String(2048), nullable=False)
    image = db.Column(db.String(260), nullable=False)
    size = db.Column(db.String(64))
    uid = db.Column(db.Integer, db.ForeignKey('user.uid'), index=True)
    status = db.Column(db.Integer, index=True)
    love = db.Column(db.Integer)
    hate = db.Column(db.Integer)
    tag = db.Column(db.String(200))
    ctime = db.Column(db.TIMESTAMP, default='0000-00-00 00:00:00')
    audit_time = db.Column(db.TIMESTAMP, default='0000-00-00 00:00:00')
    image_hash = db.Column(db.String(90))
    sameid = db.Column(db.Integer)
    samepercent = db.Column(db.Integer)
    samefrom = db.Column(db.Integer)
    img_status = db.Column(db.Integer)
    same_id = db.Column(db.Integer)
    admin_operation = db.Column(db.Integer)
    same_percent = db.Column(db.Integer)
    report_sex = db.Column(db.Integer)
    report_ad = db.Column(db.Integer)
    report_polity = db.Column(db.Integer)
    report_old = db.Column(db.Integer)
    audit_type = db.Column(db.Integer)
    comment = db.Column(db.Integer)
    rating = db.Column(db.Integer)
    post_gender = db.Column(db.Integer)
    forward = db.Column(db.Integer)
    bookmark = db.Column(db.Integer)
    image_tc = db.Column(db.String(260))
    modifytime = db.Column(db.TIMESTAMP)
    release_time = db.Column(db.TIMESTAMP, index=True)
    bimageuri  = db.Column(db.String(260))
    voiceuri = db.Column(db.String(260))
    bvoiceid = db.Column(db.Integer)
    voicetime = db.Column(db.Integer)
    voicelength = db.Column(db.Integer)
    videouri = db.Column(db.String(260))
    videotime = db.Column(db.Integer)
    type = db.Column(db.Integer)
    external_link = db.Column(db.String(512))
    theme_id = db.Column(db.Integer, index=True)
    theme_name = db.Column(db.String(100))
    theme_type = db.Column(db.Integer)
    original_pid = db.Column(db.Integer)
    audit = db.Column(db.Integer)


class User(db.Model):
    __bind_key__ = 'jie'
    __tablename__ = 'user'
    __table_args__ = {'mysql_charset': 'utf8mb4', 'mysql_engine': 'InnoDB'}

    uid = db.Column(db.Integer, primary_key=True)
    ctime = db.Column(db.TIMESTAMP, index=True, default=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
    name = db.Column(db.String(80), index=True)
    password = db.Column(db.String(32))
    header = db.Column(db.String(260))
    gender = db.Column(db.Integer)
    grade = db.Column(db.Integer, index=True)
    phone = db.Column(db.String(11))
    signature = db.Column(db.String(1024))
    platform = db.Column(db.String(16))
    qq_uid = db.Column(db.String(30), index=True)
    qq_token = db.Column(db.String(80))
    sina_uid = db.Column(db.BIGINT, index=True)
    sina_token = db.Column(db.String(80))
    qzone_uid = db.Column(db.String(32), index=True)
    qzone_token = db.Column(db.String(80))
    renren_uid = db.Column(db.BIGINT)
    renren_token = db.Column(db.String(80))
    tqq_uid = db.Column(db.String(32))
    tqq_token = db.Column(db.String(80))
    weixin_uid = db.Column(db.String(32), index=True)
    weixin_token = db.Column(db.String(128))


class AdminUser(db.Model):
    __bind_key__ = 'jie'
    __tablename__ = 'admin'
    __table_args__ = {'mysql_charset': 'utf8mb4', 'mysql_engine': 'InnoDB'}

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64))
    passwd = db.Column(db.String(64))


class Comment(db.Model):
    __bind_key__ = 'jie'
    __tablename__ = 'comment'
    __table_args__ = {'mysql_charset': 'utf8mb4', 'mysql_engine': 'InnoDB'}

    cid = db.Column(db.Integer, primary_key=True)
    pid = db.Column(db.Integer, index=True)
    uid = db.Column(db.Integer, index=True)
    atime = db.Column(db.TIMESTAMP, index=True)
    status = db.Column(db.SMALLINT, default=0)
    like_count = db.Column(db.Integer, default=0)
    body = db.Column(db.String(2048))
    name = db.Column(db.String(64))
    header = db.Column(db.String(1024))
    gender = db.Column(db.SMALLINT)
    blogid = db.Column(db.BIGINT)
    platform = db.Column(db.SMALLINT)
    apptype = db.Column(db.SMALLINT)
    platformid = db.Column(db.String(35))
    device = db.Column(db.String(16))
    precid = db.Column(db.Integer)
    preuid = db.Column(db.Integer)
    voiceuri = db.Column(db.String(300))
    voicetime = db.Column(db.Integer)
    voicelength = db.Column(db.Integer)
    report_count = db.Column(db.Integer)
    resource_id = db.Column(db.Integer)
    cmt_type = db.Column(db.SMALLINT)
    hate_count = db.Column(db.Integer)


